package com.jin.webvideo.base.util;

import org.apache.http.HttpResponse;
import org.apache.http.entity.ContentType;
import org.apache.http.util.EntityUtils;

import java.io.Closeable;
import java.io.IOException;

public class HttpClientUtil {
    public static boolean equals(ContentType contentType, ContentType type) {
        return contentType.getMimeType().equals(type.getMimeType()) &&
                contentType.getCharset().equals(type.getCharset());
    }

    public static void close(HttpResponse response) throws IOException {
        if (response == null) {
            return;
        }
        EntityUtils.consume(response.getEntity());
        if (response instanceof Closeable closeable) {
            closeable.close();
        }
    }
}
